//package work.mediway.mdm.biz.service.biz.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.mediway.common.constant.ScheduleConstants;
//import com.mediway.common.core.redis.RedisCache;
//import com.mediway.common.utils.ExceptionUtil;
//import com.mediway.dmp.etl.domain.collectionManagement.databaseConnection.DatabaseConnectionDO;
//import com.mediway.dmp.etl.domain.collectionManagement.databaseConnection.DatabaseConnectionDto;
//import com.mediway.dmp.etl.service.collectionManagement.databaseConnection.IDatabaseConnectionService;
//import com.mediway.dmp.etl.service.collectionManagement.databaseConnection.impl.DatabaseConnectionImpl;
//import com.mediway.hos.app.base.seure.util.SecurityUtils;
//import com.mediway.quartz.domain.SysJob;
//import com.mediway.quartz.mapper.SysJobMapper;
//import com.mediway.quartz.util.ScheduleUtils;
//
//import org.quartz.Scheduler;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.io.FileInputStream;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.nio.ByteBuffer;
//import java.nio.channels.FileChannel;
//import java.sql.Connection;
//import java.sql.SQLException;
//import java.util.List;
//import java.util.Map;
//import java.util.Set;
//import java.util.concurrent.Callable;
//import java.util.concurrent.ExecutorCompletionService;
//import java.util.concurrent.ThreadPoolExecutor;
//import java.util.concurrent.TimeUnit;
//import java.util.concurrent.atomic.AtomicLong;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//import javax.annotation.Resource;
//
//import cn.hutool.bloomfilter.filter.DefaultFilter;
//import cn.hutool.core.bean.BeanUtil;
//import cn.hutool.core.collection.CollUtil;
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.date.TimeInterval;
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.core.io.NioUtil;
//import cn.hutool.core.lang.Assert;
//import cn.hutool.core.map.MapUtil;
//import cn.hutool.core.util.EnumUtil;
//import cn.hutool.core.util.IdUtil;
//import cn.hutool.core.util.NumberUtil;
//import cn.hutool.core.util.ObjectUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.db.DbUtil;
//import cn.hutool.db.sql.SqlBuilder;
//import cn.hutool.json.JSONUtil;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import work.mediway.mdm.biz.bo.DataQualityConnectionBO;
//import work.mediway.mdm.biz.bo.DataQualityDataBO;
//import work.mediway.mdm.core.constant.MdmConstant;
//import work.mediway.mdm.core.enums.DataQualityDealFlagEnum;
//import work.mediway.mdm.core.enums.DataQualityExceptionDealTypeEnum;
//import work.mediway.mdm.core.enums.DataQualityExceptionTypeEnum;
//import work.mediway.mdm.core.enums.DataQualityVerifyEnum;
//import work.mediway.mdm.core.enums.StatusWhetherEnum;
//import work.mediway.mdm.core.exception.BizException;
//import work.mediway.mdm.core.exception.DataException;
//import work.mediway.mdm.core.helper.BaseDatabaseHelper;
//import work.mediway.mdm.core.thread.DimplesTaskExecutor;
//import work.mediway.mdm.core.thread.DimplesThreadPoolExecutor;
//import work.mediway.mdm.core.transport.ErrorMsgVO;
//import work.mediway.mdm.core.util.UserUtil;
//import work.mediway.mdm.core.vo.TableVO;
//import work.mediway.mdm.biz.dto.biz.DataQualityConfigDTO;
//import work.mediway.mdm.biz.dto.biz.DataQualityJobDTO;
//import work.mediway.mdm.biz.dto.biz.DataQualityListDTO;
//import work.mediway.mdm.biz.dto.biz.DataQualityVerifyDTO;
//import work.mediway.mdm.biz.entity.biz.SsDataQualityConfig;
//import work.mediway.mdm.biz.entity.biz.SsDataQualityConfigItem;
//import work.mediway.mdm.biz.entity.biz.SsDataQualityLog;
//import work.mediway.mdm.biz.entity.biz.SsDataQualityLogItem;
//import work.mediway.mdm.biz.entity.biz.SsDataQualityMapping;
//import work.mediway.mdm.biz.helper.BusinessDatabaseHelper;
//import work.mediway.mdm.biz.helper.DataPullAndCacheHelper;
//import work.mediway.mdm.biz.mapper.biz.SsDataQualityConfigMapper;
//import work.mediway.mdm.biz.service.biz.SsDataQualityConfigItemService;
//import work.mediway.mdm.biz.service.biz.SsDataQualityConfigService;
//import work.mediway.mdm.biz.service.biz.SsDataQualityLogItemService;
//import work.mediway.mdm.biz.service.biz.SsDataQualityLogService;
//import work.mediway.mdm.biz.service.biz.SsDataQualityMappingService;
//import work.mediway.mdm.biz.service.biz.SsInterSystemsService;
//import work.mediway.mdm.biz.vo.biz.DataQualityTableVO;
//import work.mediway.mdm.biz.vo.biz.SsDataQualityLogVO;
//import work.mediway.mdm.biz.vo.dict.DictFieldVO;
//
//import static work.mediway.mdm.core.constant.MdmConstant.DataQuality.BIG_DATA_THRESHOLD;
//import static work.mediway.mdm.core.constant.MdmConstant.DataQuality.DEAL_FILE_THREAD_NUM;
//import static work.mediway.mdm.core.constant.MdmConstant.DataQuality.SPLIT_THRESHOLD;
//
///**
// * @author zhongyj <1126834403@qq.com><br/>
// * @date 2022/7/11
// */
//@SuppressWarnings("ALL")
//@Slf4j
//@Service
//@RequiredArgsConstructor
//public class SsDataQualityConfigServiceImpl extends ServiceImpl<SsDataQualityConfigMapper, SsDataQualityConfig> implements SsDataQualityConfigService {
//
//    /*private final BaseDatabaseHelper baseDatabaseHelper;
//    private final BusinessDatabaseHelper businessDatabaseHelper;
//    private final SsInterSystemsService interSystemsService;
//    private final SsDataQualityConfigItemService dataQualityConfigItemService;
//    private final SsDataQualityLogService dataQualityLogService;
//    private final IDatabaseConnectionService databaseConnectionService;
//    private final RedisCache redisCache;
//    private final DataPullAndCacheHelper dataPullAndCacheHelper;
//    private final SysJobMapper jobMapper;
//    private final Scheduler scheduler;
//    private final SsDataQualityMappingService dataQualityMappingService;
//    @Resource
//    private SsDataQualityLogItemService dataQualityLogItemService;
//
//    @Override
//    public ErrorMsgVO insertDataQualityConfig(DataQualityConfigDTO dataQualityConfigDTO) {
//        if (StrUtil.isNotBlank(dataQualityConfigDTO.getSourceAccessSystemId()) && ObjectUtil.isEmpty(((DatabaseConnectionImpl) databaseConnectionService).getDatabaseConnectionDO(Long.valueOf(dataQualityConfigDTO.getSourceAccessSystemId())))) {
//            throw new DataException(StrUtil.format("源数据源Id = {} 不存在, 请先新增", dataQualityConfigDTO.getSourceAccessSystemId()));
//        }
//        if (StrUtil.isNotBlank(dataQualityConfigDTO.getTargetAccessSystemId()) && ObjectUtil.isEmpty(((DatabaseConnectionImpl) databaseConnectionService).getDatabaseConnectionDO(Long.valueOf(dataQualityConfigDTO.getTargetAccessSystemId())))) {
//            throw new DataException(StrUtil.format("目标数据源Id = {} 不存在, 请先新增", dataQualityConfigDTO.getTargetAccessSystemId()));
//        }
//        ErrorMsgVO msgVO = new ErrorMsgVO();
//        List<SsDataQualityConfig> dataQualityConfigs = dataQualityConfigDTO.getDataQualityConfigs();
//        List<DataQualityConfigDTO.TimestampField> timestampFields = dataQualityConfigDTO.getTimestampFields();
//        // 存储配置
//        for (SsDataQualityConfig dataQualityConfig : dataQualityConfigs) {
//            try {
//                dataQualityConfig.setSourceAccessSystemId(dataQualityConfigDTO.getSourceAccessSystemId());
//                dataQualityConfig.setSourceSchemaName(dataQualityConfigDTO.getSourceSchemaName());
//                dataQualityConfig.setTargetAccessSystemId(dataQualityConfigDTO.getTargetAccessSystemId());
//                dataQualityConfig.setTargetSchemaName(dataQualityConfigDTO.getTargetSchemaName());
//
//                LambdaQueryWrapper<SsDataQualityConfig> configWrapper = Wrappers.lambdaQuery(SsDataQualityConfig.class)
//                        .eq(SsDataQualityConfig::getTargetTableCode, dataQualityConfig.getTargetTableCode())
//                        .eq(SsDataQualityConfig::getTargetAccessSystemId, dataQualityConfigDTO.getTargetAccessSystemId())
//                        .eq(SsDataQualityConfig::getSourceTableCode, dataQualityConfig.getSourceTableCode())
//                        .eq(SsDataQualityConfig::getSourceAccessSystemId, dataQualityConfigDTO.getSourceAccessSystemId());
//                if (StrUtil.isNotBlank(dataQualityConfig.getTargetSchemaName())) {
//                    configWrapper.eq(SsDataQualityConfig::getTargetSchemaName, dataQualityConfigDTO.getTargetSchemaName());
//                }
//                if (StrUtil.isNotBlank(dataQualityConfig.getSourceSchemaName())) {
//                    configWrapper.eq(SsDataQualityConfig::getSourceSchemaName, dataQualityConfigDTO.getSourceSchemaName());
//                }
//                SsDataQualityConfig qualityConfig = this.getOne(configWrapper);
//
//                dataQualityConfig.setUpdateUser(UserUtil.getUsername());
//                dataQualityConfig.setUpdateDate(DateUtil.now());
//                if (ObjectUtil.isNotEmpty(qualityConfig)) {
//                    dataQualityConfig.setId(qualityConfig.getId());
//                    this.updateById(dataQualityConfig);
//                } else {
//                    // 新建配置
//                    this.save(dataQualityConfig);
//                }
//                // 新增映射配置
//                if (CollUtil.isNotEmpty(dataQualityConfig.getDataQualityConfigItems())) {
//                    this.dataQualityConfigItemService.remove(Wrappers.lambdaUpdate(SsDataQualityConfigItem.class).eq(SsDataQualityConfigItem::getDataQualityConfigId, dataQualityConfig.getId()));
//                    for (SsDataQualityConfigItem configItem : dataQualityConfig.getDataQualityConfigItems()) {
//                        configItem.setDataQualityConfigId(dataQualityConfig.getId());
//                    }
//                    this.dataQualityConfigItemService.saveBatch(dataQualityConfig.getDataQualityConfigItems());
//                }
//                // 如如果为映射源表信息中存在，那么删除
//                LambdaQueryWrapper<SsDataQualityMapping> wrapper = Wrappers.lambdaQuery(SsDataQualityMapping.class)
//                        .eq(SsDataQualityMapping::getSourceAccessSystemId, dataQualityConfigDTO.getSourceAccessSystemId())
//                        .eq(SsDataQualityMapping::getTargetAccessSystemId, dataQualityConfigDTO.getTargetAccessSystemId())
//                        .eq(SsDataQualityMapping::getTableCode, dataQualityConfig.getSourceTableCode());
//                if (StrUtil.isNotBlank(dataQualityConfig.getSourceSchemaName())) {
//                    wrapper.eq(SsDataQualityMapping::getSchemaName, dataQualityConfig.getSourceSchemaName());
//                }
//                List<SsDataQualityMapping> list = this.dataQualityMappingService.list(wrapper);
//                if (CollUtil.isNotEmpty(list)) {
//                    this.dataQualityMappingService.removeByIds(list.stream().map(SsDataQualityMapping::getId).collect(Collectors.toList()));
//                }
//            } catch (Exception e) {
//                msgVO.setErrorMsg(dataQualityConfig, e.getMessage());
//                e.printStackTrace();
//            }
//        }
//        // 存储未映射表
//        for (SsDataQualityMapping dataQualityMapping : dataQualityConfigDTO.getDataQualityMappings()) {
//            if (dataQualityMapping.getType().intValue() == 1) {
//                // 所有为未配置的源系统
//                dataQualityMapping.setSourceAccessSystemId(dataQualityConfigDTO.getSourceAccessSystemId());
//                dataQualityMapping.setSchemaName(dataQualityConfigDTO.getSourceSchemaName());
//                dataQualityMapping.setTargetAccessSystemId(dataQualityConfigDTO.getTargetAccessSystemId());
//                this.dataQualityMappingService.save(dataQualityMapping);
//            } else if (dataQualityMapping.getType().intValue() == 2) {
//                SsDataQualityConfig dataQualityConfig = new SsDataQualityConfig();
//                dataQualityConfig.setSourceAccessSystemId(dataQualityConfigDTO.getSourceAccessSystemId());
//                dataQualityConfig.setSourceSchemaName(dataQualityConfigDTO.getSourceSchemaName());
//                dataQualityConfig.setTargetAccessSystemId(dataQualityConfigDTO.getTargetAccessSystemId());
//                dataQualityConfig.setTargetSchemaName(dataQualityConfigDTO.getTargetSchemaName());
//                dataQualityConfig.setTargetTableCode(dataQualityMapping.getTableCode());
//                dataQualityConfig.setTargetTableDesc(dataQualityMapping.getTableDesc());
//                dataQualityConfig.setUpdateDate(DateUtil.now());
//                dataQualityConfig.setUpdateUser(SecurityUtils.getLoginName());
//                this.save(dataQualityConfig);
//            }
//        }
//        // 处理时间戳配置
//        for (DataQualityConfigDTO.TimestampField timestampField : timestampFields) {
//            for (DataQualityConfigDTO.TimestampField.TableInfo tableInfo : timestampField.getTableInfos()) {
//                try {
//                    LambdaQueryWrapper<SsDataQualityConfig> wrapper = Wrappers.lambdaQuery(SsDataQualityConfig.class)
//                            .eq(SsDataQualityConfig::getTargetAccessSystemId, dataQualityConfigDTO.getTargetAccessSystemId())
//                            .eq(SsDataQualityConfig::getSourceAccessSystemId, dataQualityConfigDTO.getSourceAccessSystemId())
//                            .eq(SsDataQualityConfig::getTargetTableCode, tableInfo.getTargetTableCode()
//                            );
//
//                    if (StrUtil.isNotBlank(tableInfo.getTargetSchemaName()) && !StrUtil.equalsAnyIgnoreCase(StrUtil.NULL, tableInfo.getTargetSchemaName())) {
//                        wrapper.eq(SsDataQualityConfig::getTargetSchemaName, tableInfo.getTargetSchemaName());
//                    }
//                    if (StrUtil.isNotBlank(dataQualityConfigDTO.getSourceSchemaName()) && !StrUtil.equalsAnyIgnoreCase(StrUtil.NULL, dataQualityConfigDTO.getSourceSchemaName())) {
//                        wrapper.eq(SsDataQualityConfig::getSourceSchemaName, dataQualityConfigDTO.getSourceSchemaName());
//                    }
//                    SsDataQualityConfig dataQualityConfig = this.getOne(wrapper);
//                    if (ObjectUtil.isNotEmpty(dataQualityConfig)) {
//                        SsDataQualityConfig save = new SsDataQualityConfig();
//                        save.setId(dataQualityConfig.getId());
//                        save.setTargetTimestamp(timestampField.getTimestampField());
//                        this.updateById(save);
//                    } else {
//                        SsDataQualityConfig save = new SsDataQualityConfig();
//                        save.setTargetTimestamp(timestampField.getTimestampField());
//                        save.setTargetAccessSystemId(dataQualityConfigDTO.getTargetAccessSystemId());
//                        save.setTargetTableCode(tableInfo.getTargetTableCode());
//                        if (StrUtil.isNotBlank(tableInfo.getTargetSchemaName()) && !StrUtil.equals(StrUtil.NULL, tableInfo.getTargetSchemaName())) {
//                            save.setTargetSchemaName(tableInfo.getTargetSchemaName());
//                        }
//                        save.setUpdateDate(DateUtil.now());
//                        save.setUpdateUser(SecurityUtils.getLoginName());
//                        this.save(save);
//                    }
//                } catch (Exception e) {
//                    msgVO.setErrorMsgNoIncrement(timestampField, "时间戳字段保存失败" + e.getMessage());
//                    e.printStackTrace();
//                }
//            }
//        }
//        msgVO.setCount(NumberUtil.max(dataQualityConfigs.size(), timestampFields.size()));
//        return msgVO;
//    }
//
//    @Override
//    public List<SsDataQualityConfig> selectDataQualityConfig(SsDataQualityConfig dataQualityConfig) {
//        List<SsDataQualityConfig> dataQualityConfigs = this.baseMapper.selectDataQualityConfig(dataQualityConfig);
//        if (CollUtil.isNotEmpty(dataQualityConfigs) && ObjectUtil.isNotEmpty(dataQualityConfig.getId())) {
//            for (SsDataQualityConfig qualityConfig : dataQualityConfigs) {
//                if (StrUtil.isBlank(qualityConfig.getSourceTableCode())) {
//                    qualityConfig.getDataQualityMappings().addAll(this.dataQualityMappingService.list(Wrappers.lambdaQuery(SsDataQualityMapping.class)
//                            .eq(SsDataQualityMapping::getTargetAccessSystemId, qualityConfig.getTargetAccessSystemId())
//                            .eq(SsDataQualityMapping::getType, 1)));
//                }
//            }
//
//        }
//        return dataQualityConfigs;
//    }
//
//    @Override
//    public List<Map<String, String>> selectSourceSystemSchema(String accessSystemId) {
//        List<Map<String, String>> result = CollUtil.newArrayList();
//
//        *//*DatabaseConnectionDO databaseConnectionDO = this.baseDatabaseHelper.getDatabaseConnectionDoByAccessSystemId(Long.valueOf(accessSystemId));*//*
//
//        DatabaseConnectionDO databaseConnectionDO = this.baseDatabaseHelper.getDatabaseConnectionDoByDatabaseId(Long.valueOf(accessSystemId));
//
//        String[] schemas = this.databaseConnectionService.getSchemas(databaseConnectionDO.getDatabaseConnectionId());
//        Stream.of(schemas).forEach(item -> {
//            Map<String, String> map = MapUtil.newHashMap();
//            map.put("label", item);
//            map.put("value", item);
//            result.add(map);
//        });
//        return result;
//    }
//
//    @Override
//    public List<TableVO> selectSourceSystemTable(String accessSystemId, String sourceSchema) {
//        List<TableVO> result = CollUtil.newArrayList();
//        Connection connection = this.baseDatabaseHelper.getConnectionByDatabaseId(Long.valueOf(accessSystemId));
//        result = this.baseDatabaseHelper.getTable(connection, sourceSchema, null);
//        return result;
//    }
//
//    @Override
//    public List<DictFieldVO> selectSourceSystemColumn(String accessSystemId, String sourceSchema, String tableCode) {
//        Connection connection = this.baseDatabaseHelper.getConnectionByDatabaseId(Long.valueOf(accessSystemId));
//        return this.businessDatabaseHelper.getColumn(connection, sourceSchema, tableCode);
//    }
//
//    private DatabaseConnectionDto getDatabaseConnectionDto(String accessSystemId, String sourceSchema) {
//
//        *//*DatabaseConnectionDO databaseConnectionDO = this.baseDatabaseHelper.getDatabaseConnectionDoByAccessSystemId(Long.valueOf(accessSystemId));*//*
//
//        DatabaseConnectionDO databaseConnectionDO = this.baseDatabaseHelper.getDatabaseConnectionDoByDatabaseId(Long.valueOf(accessSystemId));
//
//        DatabaseConnectionDto databaseConnectionDto = new DatabaseConnectionDto();
//        databaseConnectionDto.setDatabaseConnectionId(databaseConnectionDO.getDatabaseConnectionId());
//        databaseConnectionDto.setSchemaName(StrUtil.isBlank(sourceSchema) ? databaseConnectionDO.getDbName() : sourceSchema);
//        return databaseConnectionDto;
//    }
//
//    @Override
//    public List<String> selectMdmSystemColumn(String tableCode) {
//        return this.businessDatabaseHelper.getColumn(tableCode).stream().map(DictFieldVO::getFieldCode).collect(Collectors.toList());
//    }
//
//    @Override
//    public void startDataQualityMissing(DataQualityVerifyDTO dataQualityVerifyDTO) {
//        TimeInterval start = DateUtil.timer();
//        TimeInterval timer = DateUtil.timer();
//        log.info("=================================== 开始数据质量全量比对 ==========================================\n 比对信息：【{}】", JSONUtil.toJsonStr(dataQualityVerifyDTO));
//        DataQualityConnectionBO dataQualityConnectionBO = new DataQualityConnectionBO();
//
//        Map<Long, String> sourceFilePathTmp = MapUtil.newHashMap();
//        Map<Long, String> targetFilePathTmp = MapUtil.newHashMap();
//
//        try {
//            dataQualityConnectionBO.setLogId(dataQualityVerifyDTO.getLogId());
//            dataQualityConnectionBO.setSsDataQualityLog(verifyAndGetConnection(dataQualityVerifyDTO, dataQualityConnectionBO));
//            dataQualityConnectionBO.setKey(IdUtil.fastSimpleUUID());
//
//            // 判断是否已经存在比对信息
//            dataQualityConnectionBO.checkCompareTableExist();
//
//            DataQualityDataBO dataQualityDataBO = new DataQualityDataBO();
//
//            timer.restart();
//
//            // 查询粗略总数, 以源端近似认为双方的总数
//            log.info("=================================== 粗略查询数据总量 ==========================================");
//            long databaseDataCount = dataPullAndCacheHelper.getDatabaseDataCount(dataQualityConnectionBO.getTargetConnection(), dataQualityConnectionBO.buildTargetSelectSql(null));
//            log.info("数据总量约为: {}", databaseDataCount);
//
//            log.info("=================================== 数据质量拉取数据库数据 ==========================================");
//            // 使用多线程去同时获取源系统和目标系统数据
//            DimplesTaskExecutor<DataQualityDataBO> taskExecutor = new DimplesTaskExecutor<>("DATA-QUALITY");
//            ExecutorCompletionService<DataQualityDataBO> completionService = taskExecutor.getCompletionService();
//            List<Callable<DataQualityDataBO>> task = CollUtil.newArrayList();
//            if (databaseDataCount > BIG_DATA_THRESHOLD) {
//                // 数据量大，考虑分堆
//                dataQualityDataBO.setBucketNum(databaseDataCount / SPLIT_THRESHOLD);
//
//                // 创建对应文件以及输出流
//                for (long i = 0; i < dataQualityDataBO.getBucketNum(); i++) {
//                    Map<String, String> sourceFileStream = MapUtil.newHashMap();
//                    String sourceFile = dataQualityConnectionBO.buildTmpFile(dataQualityConnectionBO.getDataQualityConfig().getSourceTableCode(), i, 0);
//                    String targetFile = dataQualityConnectionBO.buildTmpFile(dataQualityConnectionBO.getDataQualityConfig().getTargetTableCode(), i, 1);
//                    dataQualityDataBO.getSourceFilePath().put(i, sourceFile);
//                    dataQualityDataBO.getTargetFilePath().put(i, targetFile);
//                    sourceFilePathTmp.put(i, sourceFile);
//                    targetFilePathTmp.put(i, targetFile);
//                    dataQualityDataBO.getSourceFileOutputStream().put(i, new FileOutputStream(sourceFile));
//                    dataQualityDataBO.getTargetFileOutputStream().put(i, new FileOutputStream(targetFile));
//
//                    dataQualityDataBO.getSourceFileChannel().put(i, dataQualityDataBO.getSourceFileOutputStream().get(i).getChannel());
//                    dataQualityDataBO.getTargetFileChannel().put(i, dataQualityDataBO.getTargetFileOutputStream().get(i).getChannel());
//                    dataQualityDataBO.getSourceByteBuffer().put(i, ByteBuffer.allocate(NioUtil.DEFAULT_LARGE_BUFFER_SIZE));
//                    dataQualityDataBO.getTargetByteBuffer().put(i, ByteBuffer.allocate(NioUtil.DEFAULT_LARGE_BUFFER_SIZE));
//                }
//                // HASH函数
//                DefaultFilter filter = new DefaultFilter(dataQualityDataBO.getBucketNum());
//
//                task.add(() -> {
//                    AtomicLong totalCount = new AtomicLong();
//                    log.info("查询源系统数据SQL: {}", dataQualityConnectionBO.buildSourceSelectSql(null));
//
//                    try {
//                        dataPullAndCacheHelper.pullDataFromDatabaseAndDeal(dataQualityConnectionBO.getSourceConnection()
//                                , dataQualityConnectionBO.buildSourceSelectSql(null)
//                                , CollUtil.newArrayList(dataQualityConnectionBO.getDataQualityConfigItemUnique().getSourceSystemField())
//                                , listMap -> {
//                                    listMap.forEach(map -> {
//                                        Map<String, Object> mapData = (Map<String, Object>) map;
//                                        mapData.forEach((k, v) -> {
//                                            dataWriteFile(dataQualityDataBO.getSourceFileChannel(), dataQualityDataBO.getSourceByteBuffer(), filter, v);
//                                        });
//                                        totalCount.getAndIncrement();
//                                    });
//                                    log.debug(StrUtil.format("第一次拉取源端数据，流式读取 sql = {}, 处理数据, 当前下标【{}】", dataQualityConnectionBO.buildSourceSelectSql(null)), totalCount.get());
//                                });
//                    } finally {
//                        // 关闭输出流
//                        for (long i = 0; i < dataQualityDataBO.getBucketNum(); i++) {
//                            dataQualityDataBO.getSourceFileChannel().get(i).close();
//                            dataQualityDataBO.getSourceFileOutputStream().get(i).close();
//                        }
//                    }
//                    dataQualityDataBO.setSourceCount(totalCount.get());
//                    return dataQualityDataBO;
//                });
//                task.add(() -> {
//                    AtomicLong totalCount = new AtomicLong();
//                    log.info("查询目标系统数据SQL: {}", dataQualityConnectionBO.buildTargetSelectSql(null));
//
//                    try {
//                        dataPullAndCacheHelper.pullDataFromDatabaseAndDeal(dataQualityConnectionBO.getTargetConnection()
//                                , dataQualityConnectionBO.buildTargetSelectSql(null)
//                                , CollUtil.newArrayList(dataQualityConnectionBO.getDataQualityConfigItemUnique().getTargetSystemField())
//                                , listMap -> {
//                                    listMap.forEach(map -> {
//                                        Map<String, Object> mapData = (Map<String, Object>) map;
//                                        mapData.forEach((k, v) -> {
//                                            if (dataQualityConnectionBO.isMdm()) {
//                                                v = StrUtil.removePrefixIgnoreCase(StrUtil.toString(v), "00001_");
//                                            }
//                                            dataWriteFile(dataQualityDataBO.getTargetFileChannel(), dataQualityDataBO.getTargetByteBuffer(), filter, v);
//                                        });
//                                        totalCount.getAndIncrement();
//                                    });
//                                    log.debug(StrUtil.format("第一次拉目标源端数据，流式读取 sql = {}, 处理数据, 当前下标【{}】", dataQualityConnectionBO.buildTargetSelectSql(null)), totalCount.get());
//                                });
//                    } finally {
//                        // 关闭输出流
//                        for (long i = 0; i < dataQualityDataBO.getBucketNum(); i++) {
//                            dataQualityDataBO.getTargetFileChannel().get(i).close();
//                            dataQualityDataBO.getTargetFileOutputStream().get(i).close();
//                        }
//                    }
//                    dataQualityDataBO.setTargetCount(totalCount.get());
//                    return dataQualityDataBO;
//                });
//            } else {
//                // 小数据量，直接内存比较
//                task.add(() -> {
//                    AtomicLong totalCount = new AtomicLong();
//                    log.info("查询源系统数据SQL: {}", dataQualityConnectionBO.buildSourceSelectSql(null));
//
//                    dataPullAndCacheHelper.pullDataFromDatabaseAndDeal(dataQualityConnectionBO.getSourceConnection()
//                            , dataQualityConnectionBO.buildSourceSelectSql(null)
//                            , CollUtil.newArrayList(dataQualityConnectionBO.getDataQualityConfigItemUnique().getSourceSystemField())
//                            , listMap -> {
//                                listMap.forEach(map -> {
//                                    Map<String, Object> mapData = (Map<String, Object>) map;
//                                    mapData.forEach((k, v) -> {
//                                        String id = StrUtil.toString(v);
//                                        dataQualityDataBO.getSourceData().add(id);
//                                    });
//                                    totalCount.getAndIncrement();
//                                });
//                                log.debug(StrUtil.format("第一次拉取源端数据，流式读取 sql = {}, 处理数据, 当前下标【{}】", dataQualityConnectionBO.buildSourceSelectSql(null)), totalCount.get());
//                            });
//                    dataQualityDataBO.setSourceCount(totalCount.get());
//                    return dataQualityDataBO;
//                });
//                task.add(() -> {
//                    AtomicLong totalCount = new AtomicLong();
//                    log.info("查询目标系统数据SQL: {}", dataQualityConnectionBO.buildTargetSelectSql(null));
//                    dataPullAndCacheHelper.pullDataFromDatabaseAndDeal(dataQualityConnectionBO.getTargetConnection()
//                            , dataQualityConnectionBO.buildTargetSelectSql(null)
//                            , CollUtil.newArrayList(dataQualityConnectionBO.getDataQualityConfigItemUnique().getTargetSystemField())
//                            , listMap -> {
//                                listMap.forEach(map -> {
//                                    Map<String, Object> mapData = (Map<String, Object>) map;
//                                    mapData.forEach((k, v) -> {
//                                        String id = StrUtil.toString(v);
//                                        if (dataQualityConnectionBO.isMdm()) {
//                                            id = StrUtil.removePrefixIgnoreCase(id, "00001_");
//                                        }
//                                        dataQualityDataBO.getTargetData().add(id);
//                                    });
//                                    totalCount.getAndIncrement();
//                                });
//                                log.debug(StrUtil.format("第一次拉取目标端数据，流式读取 sql = {}, 处理数据, 当前下标【{}】", dataQualityConnectionBO.buildTargetSelectSql(null)), totalCount.get());
//                            });
//                    dataQualityDataBO.setTargetCount(totalCount.get());
//                    return dataQualityDataBO;
//                });
//            }
//
//            task.forEach(completionService::submit);
//            // 获取结果
//            for (int i = 0; i < task.size(); i++) {
//                try {
//                    // 阻塞获取一下，等待所有线程跑完
//                    completionService.take().get();
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    throw new DataException(e.getMessage());
//                }
//            }
//
//            // 缓存进度
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 25);
//            task.clear();
//            log.info("数据质量拉取数据库数据用时: {}", start.intervalPretty());
//            timer.restart();
//            log.info("=================================== 数据质量拉取数据库数据完成 ==========================================");
//
//            // 开始校验
//            verifyNumber(dataQualityConnectionBO, dataQualityDataBO);
//
//            // 缓存进度
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 90);
//
//            SsDataQualityLog ssDataQualityLog = dataQualityConnectionBO.getSsDataQualityLog();
//            // 设置日志记录id
//            ssDataQualityLog.setId(Long.valueOf(dataQualityConnectionBO.getLogId()));
//            List<String> ignoreValue = getLogItemIgnoreDetail(dataQualityVerifyDTO);
//            List<SsDataQualityLogItem> dataQualityLogItems = ssDataQualityLog.getDataQualityLogItems();
//            List<SsDataQualityLogItem> saveData = CollUtil.newArrayList();
//            for (SsDataQualityLogItem dataQualityLogItem : dataQualityLogItems) {
//                log.debug("全量比较存储结果, 数据详情: {}, logId: {}", dataQualityLogItem, ssDataQualityLog.getId());
//                if (ObjectUtil.isNotEmpty(dataQualityLogItem)) {
//                    dataQualityLogItem.setLogId(ssDataQualityLog.getId());
//                    // 判断是否是忽略的数据
//                    if (CollUtil.isNotEmpty(ignoreValue)) {
//                        if (CollUtil.contains(ignoreValue, dataQualityLogItem.getLogUnique())) {
//                            break;
//                        }
//                    }
//                    saveData.add(dataQualityLogItem);
//                }
//            }
//
//            ssDataQualityLog.setMissingDataValue(String.valueOf(saveData.size()));
//            ssDataQualityLog.setSourceSystemCount(dataQualityDataBO.getSourceCount());
//            ssDataQualityLog.setTargetSystemCount(dataQualityDataBO.getTargetCount());
//            ssDataQualityLog.setUpdateDate(DateUtil.now());
//            ssDataQualityLog.setUpdateUser(UserUtil.getUsername());
//            ssDataQualityLog.setQualityType(DataQualityVerifyEnum.N.name());
//            ssDataQualityLog.setTargetTableCode(dataQualityConnectionBO.getDataQualityConfig().getTargetTableCode());
//
//            // 更新日志记录
//            this.dataQualityLogService.updateById(ssDataQualityLog);
//            // 存储日志详情
//            if (CollUtil.isNotEmpty(saveData)) {
//                this.dataQualityLogItemService.saveBatch(saveData);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//            log.error("error: {}", e.getMessage());
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 100);
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId() + "-msg", e.getMessage());
//            this.dataQualityLogService.removeById(dataQualityConnectionBO.getLogId());
//        } finally {
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 100);
//            log.info("释放数据库连接");
//            clearAll(dataQualityConnectionBO);
//            clearTmpFile(sourceFilePathTmp, targetFilePathTmp);
//            dataQualityConnectionBO.clearComparingTable();
//            log.info("=================================== 数据质量全量比对完成 ==========================================\n 用时：【{}】", start.intervalPretty());
//        }
//    }
//
//    @Override
//    public void startDataQualityError(DataQualityVerifyDTO dataQualityVerifyDTO) {
//        TimeInterval start = DateUtil.timer();
//        TimeInterval timer = DateUtil.timer();
//        log.info("=================================== 开始数据质量内容比对 ==========================================\n 比对信息：【{}】", JSONUtil.toJsonStr(dataQualityVerifyDTO));
//        DataQualityConnectionBO dataQualityConnectionBO = new DataQualityConnectionBO();
//
//        // 判断是否已经存在比对信息
//        dataQualityConnectionBO.checkCompareTableExist();
//
//        try {
//            dataQualityConnectionBO.setLogId(dataQualityVerifyDTO.getLogId());
//            dataQualityConnectionBO.setSsDataQualityLog(verifyAndGetConnection(dataQualityVerifyDTO, dataQualityConnectionBO));
//            dataQualityConnectionBO.setKey(IdUtil.fastSimpleUUID());
//            System.out.println("dataQualityConnectionBO = " + dataQualityConnectionBO);
//
//            log.info("开始查询目标系统数据");
//            long targetCount = pullTargetDataContentFromDatabase(dataQualityConnectionBO, dataQualityVerifyDTO);
//            dataQualityConnectionBO.getSsDataQualityLog().setTargetSystemCount(targetCount);
//            log.info("开始查询源系统数据");
//            long sourceCount = pullSourceDataContentFromDatabase(dataQualityConnectionBO, dataQualityVerifyDTO);
//            dataQualityConnectionBO.getSsDataQualityLog().setSourceSystemCount(sourceCount);
//
//            // 存储主键值
//            List<String> sourceUniqueId = CollUtil.newArrayList();
//            List<String> targetUniqueId = CollUtil.newArrayList();
//            // 拉取缓存中的Map数据，构造给数量和内容比对的数据结构
//            dataPullAndCacheHelper.pullDataFormCache(dataQualityConnectionBO.buildTargetContentCacheKeyList(), targetCount, (mapList) -> {
//                mapList.forEach(map -> {
//                    Map<String, Object> dataMap = (Map<String, Object>) map;
//                    String uniqueVal = StrUtil.toString(dataMap.get(dataQualityConnectionBO.getDataQualityConfigItemUnique().getTargetSystemField()));
//                    targetUniqueId.add(uniqueVal);
//
//                    // 主键值为key，完整数据为value，进行存储
//                    redisCache.setCacheObject(dataQualityConnectionBO.buildTargetUniqueMapCacheKeyC(uniqueVal), dataMap);
//                });
//            });
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 35);
//            // 从缓存中获取数据
//            dataPullAndCacheHelper.pullDataFormCache(dataQualityConnectionBO.buildSourceContentCacheKeyList(), sourceCount, (mapList) -> {
//                mapList.forEach(map -> {
//                    Map<String, Object> dataMap = (Map<String, Object>) map;
//                    String uniqueVal = StrUtil.toString(dataMap.get(dataQualityConnectionBO.getDataQualityConfigItemUnique().getSourceSystemField()));
//                    sourceUniqueId.add(uniqueVal);
//
//                    // 主键值为key，完整数据为value，进行存储
//                    redisCache.setCacheObject(dataQualityConnectionBO.buildSourceUniqueMapCacheKeyC(uniqueVal), dataMap);
//                });
//            });
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 40);
//            // 比对数量
//            DataQualityDataBO dataQualityDataBO = new DataQualityDataBO();
//            verifyDataNumFromCache(sourceUniqueId, targetUniqueId, dataQualityConnectionBO, dataQualityDataBO);
//
//            // 比对内容
//            sourceUniqueId.forEach(uniqueVal -> {
//                if ((!CollUtil.contains(dataQualityDataBO.getSourceNoExist(), uniqueVal))
//                        && (!CollUtil.contains(dataQualityDataBO.getTargetNoExist(), uniqueVal))) {
//                    // 说明源系统和目标系统都存在改唯一值, 可以获取数据进行比对
//
//                    // 从缓存中获取数据
//                    Map<String, Object> contentSource = (Map<String, Object>) redisCache.getCacheObject(dataQualityConnectionBO.buildSourceUniqueMapCacheKeyC(uniqueVal));
//                    log.debug("清除redis数据：{}", dataQualityConnectionBO.buildSourceUniqueMapCacheKeyC(uniqueVal));
//                    redisCache.deleteObject(dataQualityConnectionBO.buildSourceUniqueMapCacheKeyC(uniqueVal));
//
//                    Map<String, Object> contentTaeget = (Map<String, Object>) redisCache.getCacheObject(dataQualityConnectionBO.buildTargetUniqueMapCacheKeyC(uniqueVal));
//                    log.debug("清除redis数据：{}", dataQualityConnectionBO.buildTargetUniqueMapCacheKeyC(uniqueVal));
//                    redisCache.deleteObject(dataQualityConnectionBO.buildTargetUniqueMapCacheKeyC(uniqueVal));
//
//                    dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 80);
//                    // 比对
//                    for (SsDataQualityConfigItem configItem : dataQualityConnectionBO.getDataQualityConfig().getDataQualityConfigItems()) {
//                        if (StrUtil.equals(StrUtil.toString(contentSource.get(configItem.getSourceSystemField()))
//                                , StrUtil.toString(contentTaeget.get(configItem.getTargetSystemField())))) {
//                        } else {
//                            SsDataQualityLogItem dataQualityLogItem = new SsDataQualityLogItem();
//                            dataQualityLogItem.setLogUnique(uniqueVal);
//                            dataQualityLogItem.setLogData(StrUtil.format("{}: 【{}】; {}: 【{}】"
//                                    , dataQualityConnectionBO.getDataQualityConfig().getSourceAccessSystem()
//                                    , JSONUtil.toJsonStr(contentSource)
//                                    , dataQualityConnectionBO.getDataQualityConfig().getTargetAccessSystem()
//                                    , JSONUtil.toJsonStr(contentTaeget)));
//                            dataQualityLogItem.setDataExceptionType(DataQualityExceptionTypeEnum.CONTENT_ERROR.getType());
//                            dataQualityLogItem.setDealFlag(DataQualityDealFlagEnum.UN_DEAL.getType());
//                            dataQualityConnectionBO.getSsDataQualityLog().getDataQualityLogItems().add(dataQualityLogItem);
//                            break;
//                        }
//                    }
//
//                    dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 90);
//                }
//            });
//
//            SsDataQualityLog ssDataQualityLog = dataQualityConnectionBO.getSsDataQualityLog();
//            List<SsDataQualityLogItem> dataQualityLogItems = ssDataQualityLog.getDataQualityLogItems();
//            // 设置日志记录id
//            ssDataQualityLog.setId(Long.valueOf(dataQualityConnectionBO.getLogId()));
//            List<String> ignoreValue = getLogItemIgnoreDetail(dataQualityVerifyDTO);
//            List<SsDataQualityLogItem> saveData = CollUtil.newArrayList();
//            for (SsDataQualityLogItem dataQualityLogItem : dataQualityLogItems) {
//                dataQualityLogItem.setLogId(ssDataQualityLog.getId());
//                // 判断是否是忽略的数据
//                if (CollUtil.isNotEmpty(ignoreValue)) {
//                    if (CollUtil.contains(ignoreValue, dataQualityLogItem.getLogUnique())) {
//                        break;
//                    }
//                }
//                saveData.add(dataQualityLogItem);
//            }
//
//            ssDataQualityLog.setErrorDataValue(String.valueOf(saveData.size()));
//            ssDataQualityLog.setUpdateDate(DateUtil.now());
//            ssDataQualityLog.setUpdateUser(UserUtil.getUsername());
//            ssDataQualityLog.setQualityType(DataQualityVerifyEnum.C.name());
//            ssDataQualityLog.setTargetTableCode(dataQualityConnectionBO.getDataQualityConfig().getTargetTableCode());
//
//            // 更新日志记录
//            this.dataQualityLogService.updateById(ssDataQualityLog);
//            // 存储日志详情
//            if (CollUtil.isNotEmpty(saveData)) {
//                this.dataQualityLogItemService.saveBatch(saveData);
//            }
//            this.clearAll(dataQualityConnectionBO);
//        } catch (Exception e) {
//            log.error(ExceptionUtil.getExceptionMessage(e));
//            log.error("SQL error: {}", e.getMessage());
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 100);
//            dataQualityPlanCache(dataQualityConnectionBO.getLogId() + "-msg", e.getMessage());
//            this.dataQualityLogService.removeById(dataQualityConnectionBO.getLogId());
//        } finally {
//            log.info("释放数据库连接");
//            clearAll(dataQualityConnectionBO);
//            log.info("=================================== 数据质量内容比对完成 ==========================================\n 用时：【{}】", start.intervalPretty());
//        }
//        dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 100);
//    }
//
//    private List<String> getLogItemIgnoreDetail(DataQualityVerifyDTO dataQualityVerifyDTO) {
//        List<String> ignoreValue = CollUtil.newArrayList();
//        LambdaQueryWrapper<SsDataQualityLog> logWrapper = Wrappers.lambdaQuery(SsDataQualityLog.class).eq(SsDataQualityLog::getDataQualityConfigId, dataQualityVerifyDTO.getConfigId());
//        List<SsDataQualityLog> qualityLogs = this.dataQualityLogService.list(logWrapper);
//        if (CollUtil.isNotEmpty(qualityLogs)) {
//            LambdaQueryWrapper<SsDataQualityLogItem> logItemWrapper = Wrappers
//                    .lambdaQuery(SsDataQualityLogItem.class)
//                    .in(SsDataQualityLogItem::getLogId, qualityLogs.stream().map(SsDataQualityLog::getId).collect(Collectors.toList()))
//                    .eq(SsDataQualityLogItem::getDealFlag, DataQualityDealFlagEnum.DEAL.getType())
//                    .eq(SsDataQualityLogItem::getDealType, DataQualityExceptionDealTypeEnum.IGNORE.getType());
//            List<SsDataQualityLogItem> qualityLogItems = this.dataQualityLogItemService.list(logItemWrapper);
//            if (CollUtil.isNotEmpty(qualityLogItems)) {
//                ignoreValue.addAll(qualityLogItems.stream().map(SsDataQualityLogItem::getLogUnique).distinct().collect(Collectors.toList()));
//            }
//        }
//        return ignoreValue;
//    }
//
//    private void clearAll(DataQualityConnectionBO dataQualityConnectionBO) {
//        log.info("释放数据库连接");
//        DbUtil.close(dataQualityConnectionBO.getSourceConnection());
//        DbUtil.close(dataQualityConnectionBO.getTargetConnection());
//        if (ObjectUtil.isNotEmpty(dataQualityConnectionBO.getDataQualityConfig()) && ObjectUtil.isNotEmpty(dataQualityConnectionBO.getDataQualityConfigItemUnique())) {
//            redisCache.deleteObject(dataQualityConnectionBO.buildSourceContentCacheKeyList());
//            redisCache.deleteObject(dataQualityConnectionBO.buildTargetContentCacheKeyList());
//            log.info(StrUtil.format("清空redis缓存数据: {}, {}"
//                    , dataQualityConnectionBO.buildSourceContentCacheKeyList()
//                    , dataQualityConnectionBO.buildTargetContentCacheKeyList())
//            );
//        }
//    }
//
//    private void clearTmpFile(Map<Long, String> sourceFilePath, Map<Long, String> targetFilePath) {
//        for (long i = 0; i < sourceFilePath.size(); i++) {
//            log.info("删除数据质量比对文件, 源端文件: {}", sourceFilePath.get(i));
//            try {
//                FileUtil.del(sourceFilePath.get(i));
//            } catch (Exception e) {
//                log.error("文件: {} 删除失败", sourceFilePath.get(i));
//            }
//        }
//        for (long i = 0; i < targetFilePath.size(); i++) {
//            log.info("删除数据质量比对文件, 目标端文件: {}", targetFilePath.get(i));
//            try {
//                FileUtil.del(targetFilePath.get(i));
//            } catch (Exception e) {
//                log.error("文件: {} 删除失败", targetFilePath.get(i));
//            }
//        }
//    }
//
//    *//**
//     * 查询系统信息并获取数据库连接
//     *
//     * @param dataQualityVerifyDTO    DataQualityVerifyDTO
//     * @param dataQualityConnectionBO DataQualityConnectionBO
//     * @return SsDataQualityLog
//     *//*
//    @Override
//    public SsDataQualityLog verifyAndGetConnection(DataQualityVerifyDTO dataQualityVerifyDTO, DataQualityConnectionBO dataQualityConnectionBO) {
//        SsDataQualityLog ssDataQualityLog = new SsDataQualityLog();
//        // 根据tableCode查询去来源系统信息
//        SsDataQualityConfig config = new SsDataQualityConfig();
//        config.setId(Integer.valueOf(dataQualityVerifyDTO.getConfigId()));
//        List<SsDataQualityConfig> qualityConfigs = this.selectDataQualityConfig(config);
//
//        if (CollUtil.isEmpty(qualityConfigs)) {
//            throw new DataException(StrUtil.format("configId = {} 未找到该配置信息"));
//        }
//        SsDataQualityConfig qualityConfig = qualityConfigs.get(0);
//        // 判断目标系统是否为主数据
//        if (StrUtil.equalsAnyIgnoreCase(qualityConfig.getTargetSchemaName(), MdmConstant.SCHEMA_NAME)) {
//            dataQualityConnectionBO.setMdm(true);
//        }
//        // 查询字典对照配置
//        List<SsDataQualityConfig> dataQualityConfigs = this.selectDataQualityConfig(qualityConfig);
//        if (CollUtil.isEmpty(dataQualityConfigs)) {
//            throw new DataException(StrUtil.format("系统 = {} 同时 表 = {} 时未查询到对应的对照信息, 请先维护", qualityConfig.getSourceAccessSystem(), qualityConfig.getTargetTableCode()));
//        }
//        if (CollUtil.isEmpty(qualityConfig.getDataQualityConfigItems())) {
//            throw new DataException(StrUtil.format("系统 = {} 同时 表 = {} 时未查询到对应的字段对照信息, 请先维护", qualityConfig.getSourceAccessSystem(), qualityConfig.getTargetTableCode()));
//        }
//        // 对照信息
//        Assert.isTrue(dataQualityConfigs.size() == 1);
//        dataQualityConnectionBO.setDataQualityConfig(dataQualityConfigs.get(0));
//        // 设置管理配置信息
//        ssDataQualityLog.setDataQualityConfigId(Long.valueOf(dataQualityConnectionBO.getDataQualityConfig().getId()));
//        // 获取唯一标识字段
//        List<SsDataQualityConfigItem> unique = dataQualityConnectionBO.getDataQualityConfig().getDataQualityConfigItems().stream()
//                .filter(item -> StrUtil.equalsAnyIgnoreCase(StatusWhetherEnum.STATUS_Y.getStatusCode(), item.getUniqueFlag()))
//                .collect(Collectors.toList());
//        if (CollUtil.isEmpty(unique)) {
//            throw new DataException(StrUtil.format("系统 = {} 同时 表 = {} 时未查询到对应唯一键信息, 请先维护", qualityConfig.getSourceAccessSystemId(), qualityConfig.getTargetTableCode()));
//        }
//        dataQualityConnectionBO.setDataQualityConfigItemUnique(unique.get(0));
//        return ssDataQualityLog;
//    }
//
//    *//**
//     * 数据库数据写入文件
//     *
//     * @param fileChannel Map<Long, FileChannel>
//     * @param byteBuffer  Map<Long, ByteBuffer>
//     * @param filter      DefaultFilter
//     * @param v           Object
//     *//*
//    private void dataWriteFile(Map<Long, FileChannel> fileChannel, Map<Long, ByteBuffer> byteBuffer, DefaultFilter filter, Object v) {
//        String id = StrUtil.toString(v);
//        long hash = Math.abs(filter.hash(id));
//        // 获取相应的channel
//        FileChannel channel = fileChannel.get(hash);
//        ByteBuffer buffer = byteBuffer.get(hash);
//        //将字符串以字节形式放入buffer中
//        byte[] bytes = (id + StrUtil.COMMA).getBytes();
//        if (buffer.remaining() > bytes.length) {
//            buffer.put(bytes);
//        } else {
//            //开始读取
//            buffer.flip();
//            //从buffer中读取到文件
//            try {
//                channel.write(buffer);
//                buffer.clear();
//            } catch (IOException e) {
//                e.printStackTrace();
//                log.error("nio 写入源端数据");
//            }
//            buffer.put(bytes);
//        }
//        //开始读取
//        buffer.flip();
//        //从buffer中读取到文件
//        try {
//            channel.write(buffer);
//            buffer.clear();
//        } catch (IOException e) {
//            e.printStackTrace();
//            log.error("nio 写入源端数据");
//        }
//    }
//
//    *//**
//     * 校验数量
//     *
//     * @param dataQualityConnectionBO DataQualityConnectionBO
//     * @param dataQualityDataBO       DataQualityDataBO
//     * @throws SQLException SQLException
//     *//*
//    private void verifyNumber(DataQualityConnectionBO dataQualityConnectionBO, DataQualityDataBO dataQualityDataBO) throws Exception {
//        TimeInterval timer = DateUtil.timer();
//
//        DimplesTaskExecutor<DataQualityDataBO> taskExecutor = new DimplesTaskExecutor<>("DATA-QUALITY");
//        ExecutorCompletionService<DataQualityDataBO> completionService = taskExecutor.getCompletionService();
//        List<Callable<DataQualityDataBO>> task = CollUtil.newArrayList();
//
//        if (dataQualityDataBO.getSourceCount() > BIG_DATA_THRESHOLD) {
//            task.add(() -> {
//                for (int i = 0; i < dataQualityDataBO.getBucketNum(); i++) {
//                    long finalI = i;
//                    String sourceData = "";
//                    String targetData = "";
//                    String sourceFilePath = dataQualityDataBO.getSourceFilePath().get(finalI);
//                    String targetFilePath = dataQualityDataBO.getTargetFilePath().get(finalI);
//                    // 读取源端数据
//                    FileInputStream sourceFileInputStream = new FileInputStream(sourceFilePath);
//                    FileInputStream targetFileInputStream = new FileInputStream(targetFilePath);
//                    FileChannel sourceChannel = sourceFileInputStream.getChannel();
//                    FileChannel targetChannel = targetFileInputStream.getChannel();
//                    ByteBuffer sourceBuffer = ByteBuffer.allocate(NioUtil.DEFAULT_LARGE_BUFFER_SIZE);
//                    ByteBuffer targetBuffer = ByteBuffer.allocate(NioUtil.DEFAULT_LARGE_BUFFER_SIZE);
//
//                    try {
//                        sourceData = NioUtil.readUtf8(sourceChannel);
//                        targetData = NioUtil.readUtf8(targetChannel);
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    } finally {
//                        sourceChannel.close();
//                        targetChannel.close();
//                        sourceFileInputStream.close();
//                        targetFileInputStream.close();
//                        NioUtil.close(sourceChannel);
//                        NioUtil.close(targetChannel);
//                    }
//                    // 查找不同
//                    List<String> sourceDataList = StrUtil.splitTrim(sourceData, StrUtil.COMMA);
//                    List<String> targetDataList = StrUtil.splitTrim(targetData, StrUtil.COMMA);
//                    log.info("读取源端文件: {}, 总数量: {}, 开始比对", sourceFilePath, sourceDataList.size());
//                    log.info("读取目标端文件: {}, 总数量: {}, 开始比对", targetFilePath, targetDataList.size());
//                    List<String> targetMiss = CollUtil.subtractToList(sourceDataList, targetDataList);
//                    List<String> sourceMiss = CollUtil.subtractToList(targetDataList, sourceDataList);
//                    log.info("目标端比对结果: 源端缺失数量: {}, 目标端缺失数量: {}", sourceMiss.size(), targetMiss.size());
//                    dataQualityDataBO.getTargetNoExist().addAll(targetMiss);
//                    dataQualityDataBO.getSourceNoExist().addAll(sourceMiss);
//                }
//                return dataQualityDataBO;
//            });
//        } else {
//            task.add(() -> {
//                List<String> targetMiss = CollUtil.subtractToList(dataQualityDataBO.getSourceData(), dataQualityDataBO.getTargetData());
//                dataQualityDataBO.getTargetNoExist().addAll(targetMiss);
//                return dataQualityDataBO;
//            });
//            task.add(() -> {
//                List<String> sourceMiss = CollUtil.subtractToList(dataQualityDataBO.getTargetData(), dataQualityDataBO.getSourceData());
//                dataQualityDataBO.getSourceNoExist().addAll(sourceMiss);
//                return dataQualityDataBO;
//            });
//        }
//        List<List<Callable<DataQualityDataBO>>> taskSplit = CollUtil.split(task, DEAL_FILE_THREAD_NUM);
//        for (List<Callable<DataQualityDataBO>> callables : taskSplit) {
//            for (Callable<DataQualityDataBO> callable : callables) {
//                callables.forEach(completionService::submit);
//            }
//            // 获取结果
//            for (int i = 0; i < callables.size(); i++) {
//                try {
//                    // 阻塞获取一下，等待所有线程跑完
//                    completionService.take().get();
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    throw new DataException(e.getMessage());
//                }
//            }
//        }
//
//        dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 50);
//
//        log.info("=================================== 数据质量第校验(数据库查找)开始 ==========================================");
//        log.info("源系统缺失数量: {}, 目标系统缺失数量: {} ==========================================", dataQualityDataBO.getSourceNoExist().size(), dataQualityDataBO.getTargetNoExist().size());
//        timer.restart();
//        verifyDataExistFromDatabase(dataQualityConnectionBO, dataQualityDataBO);
//        log.info("数据质量第二次校验比对完成, 共计用时: {}", timer.intervalPretty());
//        log.info("=================================== 数据质量第校验(数据库查找)结束 ==========================================");
//    }
//
//    *//**
//     * 内容比对时数据数量校验
//     *
//     * @param dataQualityConnectionBO DataQualityConnectionBO
//     * @param dataQualityDataBO       DataQualityDataBO
//     *//*
//    private void verifyDataNumFromCache(List<String> sourceUniqueId, List<String> targetUniqueId, DataQualityConnectionBO dataQualityConnectionBO, DataQualityDataBO dataQualityDataBO) throws Exception {
//        List<String> targetMiss = CollUtil.subtractToList(sourceUniqueId, targetUniqueId);
//        dataQualityDataBO.getTargetNoExist().addAll(targetMiss);
//
//        List<String> sourceMiss = CollUtil.subtractToList(targetUniqueId, sourceUniqueId);
//        dataQualityDataBO.getSourceNoExist().addAll(sourceMiss);
//        dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 50);
//        verifyDataExistFromDatabase(dataQualityConnectionBO, dataQualityDataBO);
//    }
//
//    *//**
//     * 对第一次验证数量结果，再去数据库查询验证一次，以防在此过程中有数据同步进来
//     *
//     * @param dataQualityConnectionBO DataQualityConnectionBO
//     * @param dataQualityDataBO       DataQualityDataBO
//     * @throws SQLException
//     *//*
//    private void verifyDataExistFromDatabase(DataQualityConnectionBO dataQualityConnectionBO, DataQualityDataBO dataQualityDataBO) throws SQLException {
//        log.info("当前源系统总数: {}, 目标系统总数: {}, 源系统不存在总数: {}, 目标系统不存在总数: {}", dataQualityDataBO.getSourceCount(), dataQualityDataBO.getTargetCount()
//                , dataQualityDataBO.getSourceNoExist().size(), dataQualityDataBO.getTargetNoExist().size());
//        // 缺失数据唯一值集合
//        Set<SsDataQualityLogItem> targetDisResult = CollUtil.newHashSet();
//
//        DimplesTaskExecutor<Boolean> taskExecutor = new DimplesTaskExecutor<>();
//        ExecutorCompletionService<Boolean> completionService = taskExecutor.getCompletionService();
//        List<Callable<Boolean>> task = CollUtil.newArrayList();
//
//        // 如果源系统有缺少，那么再去源系统查询一次
//        if (dataQualityDataBO.getSourceNoExist().size() > 0) {
//            task.add(() -> {
//                *//*//*/ 如果源系统确失的值，再去数据库查询一次，以防因为时间差导致的数据查询遗漏
//                List<String> in = CollUtil.newArrayList();
//                dataQualityDataBO.getSourceNoExist().forEach(item -> in.add("'" + item + "'"));
//                dataQualityDataBO.getSourceNoExist().clear();
//                if (CollUtil.isNotEmpty(in)) {
//                    List<List<String>> vals = CollUtil.split(in, 100);
//                    Connection sourceConnection = dataQualityConnectionBO.getSourceConnection();
//                    try {
//                        // 分批去数据库查询是否存在
//                        for (List<String> val : vals) {
//                            List<String> tmp = CollUtil.newArrayList();
//                            val.forEach(v -> tmp.add(StrUtil.removeAll(v, "'")));
//                            log.debug("数据全量比对, 查询源数据库：{}", dataQualityConnectionBO.buildSourceSelectSql(val));
//
//                            List<String> querySourceAgain = SqlExecutor.query(sourceConnection, dataQualityConnectionBO.buildSourceSelectSql(val), new BeanListHandler<>(String.class));
//                            log.info("查询源系统数据入参: {}", StrUtil.join(",", tmp));
//                            log.info("查询源系统数据结果: {}", StrUtil.join(",", querySourceAgain));
//                            if (CollUtil.isEmpty(querySourceAgain)) {
//                                dataQualityDataBO.getSourceNoExist().addAll(tmp);
//                            } else {
//                                dataQualityDataBO.getSourceNoExist().addAll(CollUtil.subtractToList(tmp, querySourceAgain));
//                                log.info("查询源系统数据差值: {}", StrUtil.join(",", CollUtil.subtractToList(tmp, querySourceAgain)));
//                            }
//                        }
//                    } catch (Exception e) {
//                        throw new BizException("数据全量比对, 查询源数据库", e);
//                    } finally {
//                        try {
//                            sourceConnection.close();
//                        } catch (SQLException e) {
//                            throw new BizException("关闭源数据库连接失败", e);
//                        }
//                    }
//                }*//*
//                List<String> idExist = CollUtil.newArrayList();
//                for (String dis : dataQualityDataBO.getSourceNoExist()) {
//                    if (!CollUtil.contains(idExist, dis)) {
//                        SsDataQualityLogItem dataQualityLogItem = new SsDataQualityLogItem();
//                        dataQualityLogItem.setLogUnique(dis);
//                        dataQualityLogItem.setLogData(dis);
//                        dataQualityLogItem.setDataExceptionType(DataQualityExceptionTypeEnum.SOURCE_MISS.getType());
//                        dataQualityLogItem.setDealFlag(DataQualityDealFlagEnum.UN_DEAL.getType());
//                        targetDisResult.add(dataQualityLogItem);
//                        idExist.add(dis);
//                    }
//                }
//                return true;
//            });
//        }
//        // 如果目标系统没有
//        if (dataQualityDataBO.getTargetNoExist().size() > 0) {
//            task.add(() -> {
//                *//*List<String> in = CollUtil.newArrayList();
//                dataQualityDataBO.getTargetNoExist().forEach(item -> in.add("'" + item + "'"));
//                dataQualityDataBO.getTargetNoExist().clear();
//                if (CollUtil.isNotEmpty(in)) {
//                    List<List<String>> vals = CollUtil.split(in, 100);
//                    Connection targetConnection = dataQualityConnectionBO.getTargetConnection();
//                    try {
//                        for (List<String> val : vals) {
//                            List<String> tmp = CollUtil.newArrayList();
//                            val.forEach(v -> tmp.add(StrUtil.removeAll(v, "'")));
//                            log.debug("数据全量比对, 查询目标数据库：{}", dataQualityConnectionBO.buildTargetSelectSql(val));
//
//                            List<String> queryTargetAgain = SqlExecutor.query(targetConnection, dataQualityConnectionBO.buildTargetSelectSql(val), new BeanListHandler<>(String.class));
//                            log.info("查询目标系统数据入参: {}", StrUtil.join(",", tmp));
//                            log.info("查询目标系统数据结果: {}", StrUtil.join(",", queryTargetAgain));
//                            if (CollUtil.isEmpty(queryTargetAgain)) {
//                                dataQualityDataBO.getTargetNoExist().addAll(tmp);
//                            } else {
//                                dataQualityDataBO.getTargetNoExist().addAll(CollUtil.subtractToList(tmp, queryTargetAgain));
//                                log.info("查询目标系统数据差值: {}", StrUtil.join(",", CollUtil.subtractToList(tmp, queryTargetAgain)));
//                                dataQualityDataBO.setTargetCount(dataQualityDataBO.getTargetCount() + queryTargetAgain.size());
//                                log.info("更新目标系统总数据量: {}", dataQualityDataBO.getTargetCount());
//                            }
//                        }
//                    } catch (Exception e) {
//                        throw new BizException("数据全量比对, 查询目标数据库", e);
//                    } finally {
//                        try {
//                            targetConnection.close();
//                        } catch (SQLException e) {
//                            throw new BizException("关闭目标数据库连接失败", e);
//                        }
//                    }
//                }*//*
//                List<String> idExist = CollUtil.newArrayList();
//                for (String dis : dataQualityDataBO.getTargetNoExist()) {
//                    if (!CollUtil.contains(idExist, dis)) {
//                        SsDataQualityLogItem dataQualityLogItem = new SsDataQualityLogItem();
//                        dataQualityLogItem.setLogUnique(dis);
//                        dataQualityLogItem.setLogData(dis);
//                        dataQualityLogItem.setDataExceptionType(DataQualityExceptionTypeEnum.TARGET_MISS.getType());
//                        dataQualityLogItem.setDealFlag(DataQualityDealFlagEnum.UN_DEAL.getType());
//                        targetDisResult.add(dataQualityLogItem);
//                    }
//                }
//                return true;
//            });
//        }
//
//        *//*//*/ 根据数量判断是否需要等待，暂停5分钟，等待因为时间差同步
//        if (dataQualityDataBO.getTargetCount() > WAIT_THRESHOLD) {
//            try {
//                TimeUnit.MINUTES.sleep(3);
//            } catch (InterruptedException e) {
//                log.error(ExceptionUtil.getExceptionMessage(e));
//            }
//        }*//*
//        task.forEach(item -> {
//            completionService.submit(item);
//        });
//        for (int i = 0; i < task.size(); i++) {
//            try {
//                completionService.take().get();
//            } catch (Exception e) {
//                throw new DataException(e.getMessage());
//            }
//        }
//        dataQualityConnectionBO.getSsDataQualityLog().getDataQualityLogItems().addAll(targetDisResult);
//
//        dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 75);
//    }
//
//    *//**
//     * 内容比对获取目标系统详细信息并缓存
//     *
//     * @param dataQualityConnectionBO DataQualityConnectionBO
//     * @param dataQualityVerifyDTO    DataQualityVerifyDTO
//     * @param targetCacheKey          String
//     * @return long
//     * @throws SQLException SQLException
//     *//*
//    private long pullTargetDataContentFromDatabase(DataQualityConnectionBO dataQualityConnectionBO, DataQualityVerifyDTO dataQualityVerifyDTO) throws SQLException {
//        // 找日期字段
////        String dateField = databaseHelper.calculateTableDateField(dataQualityConnectionBO.getTargetConnection(), dataQualityConnectionBO.getTargetSchema(), dataQualityConnectionBO.getDataQualityConfig().getTargetTableCode());
//        String dateField = dataQualityConnectionBO.getDataQualityConfig().getTargetTimestamp();
//        List<String> targetFields = dataQualityConnectionBO.getAllTargetField();
//        // 获取主键字段
//        String targetSystemField = dataQualityConnectionBO.getDataQualityConfigItemUnique().getTargetSystemField();
//        // 主键值集合
//        List<Object> value = CollUtil.newArrayList();
//
//        if (StrUtil.isBlank(dataQualityVerifyDTO.getEndDate())) {
//            dataQualityVerifyDTO.setEndDate(DateUtil.today());
//        }
//        if (StrUtil.isBlank(dataQualityVerifyDTO.getStartDate())) {
//            dataQualityVerifyDTO.setEndDate(DateUtil.today());
//        }
//        SqlBuilder targetDataSql = SqlBuilder.create()
//                .select(targetFields)
//                .from(dataQualityConnectionBO.getTargetSchemaTable())
//                .where(dateField + " >= '" + dataQualityVerifyDTO.getStartDate() + "' AND " + dateField + " <= '" + dataQualityVerifyDTO.getEndDate() + "'")
//                .groupBy(dataQualityConnectionBO.getDataQualityConfigItemUnique().getTargetSystemField());
//        log.info("内容比对查询目标系统数据SQL：{}", targetDataSql);
//        // 流式查询数据并缓存
//        long count = dataPullAndCacheHelper.pullDataFromDatabase(dataQualityConnectionBO.getTargetConnection(), targetDataSql.build(), dataQualityConnectionBO.buildTargetContentCacheKeyList(), targetFields);
//
//        if (count == 0) {
//            throw new DataException(StrUtil.format("日期【{}至{}内目标系统中未查询到数据】", dataQualityVerifyDTO.getStartDate(), dataQualityVerifyDTO.getEndDate()));
//        }
//        dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 20);
//        return count;
//    }
//
//    *//**
//     * 内容比对获取源系统详细信息并缓存
//     *
//     * @param dataQualityConnectionBO DataQualityConnectionBO
//     * @param dataQualityVerifyDTO    DataQualityVerifyDTO
//     * @return long
//     * @throws SQLException SQLException
//     *//*
//    private long pullSourceDataContentFromDatabase(DataQualityConnectionBO dataQualityConnectionBO, DataQualityVerifyDTO dataQualityVerifyDTO) {
//        AtomicLong count = new AtomicLong();
//        dataPullAndCacheHelper.pullDataFormCache(dataQualityConnectionBO.buildTargetContentCacheKeyList(), dataQualityConnectionBO.getSsDataQualityLog().getTargetSystemCount(), (data) -> {
//            List<String> in = CollUtil.newArrayList();
//            List<String> sourceFields = dataQualityConnectionBO.getAllSourceField();
//            data.forEach(item -> {
//                Map<String, Object> dataMap = (Map<String, Object>) item;
//                in.add("'" + dataMap.get(dataQualityConnectionBO.getDataQualityConfigItemUnique().getTargetSystemField()) + "'");
//            });
//
//            log.info("内容比对拉取源系统数据SQL: {}", dataQualityConnectionBO.buildSourceSelectSql(in, sourceFields));
//            count.addAndGet(dataPullAndCacheHelper.pullDataFromDatabase(dataQualityConnectionBO.getSourceConnection(), dataQualityConnectionBO.buildSourceSelectSql(in, sourceFields), dataQualityConnectionBO.buildSourceContentCacheKeyList(), sourceFields));
//        });
//        dataQualityPlanCache(dataQualityConnectionBO.getLogId(), 30);
//        return count.get();
//    }
//
//    @Override
//    public List<SsDataQualityLogVO> startDataQuality(List<DataQualityVerifyDTO> dataQualityVerifyDTOList) {
//        List<SsDataQualityLogVO> result = CollUtil.newArrayList();
//
//        ThreadPoolExecutor executor = DimplesThreadPoolExecutor.getExecutor();
//        List<Runnable> runnables = CollUtil.newArrayList();
//
//        for (DataQualityVerifyDTO dataQualityVerifyDTO : dataQualityVerifyDTOList) {
//            for (DataQualityVerifyEnum dataQualityVerifyEnum : dataQualityVerifyDTO.getDataQualityVerifyEnum()) {
//                // 真正比对，异步
//                if (EnumUtil.equals(DataQualityVerifyEnum.N, dataQualityVerifyEnum.name())) {
//                    // 先生成对应的比对id信息
//                    DataQualityVerifyDTO buildLogId = buildLogId(result, dataQualityVerifyDTO, dataQualityVerifyEnum);
//                    // 全量信息
//                    runnables.add(() -> startDataQualityMissing(buildLogId));
//                } else if (EnumUtil.equals(DataQualityVerifyEnum.C, dataQualityVerifyEnum.name())) {
//                    DataQualityVerifyDTO buildLogId = buildLogId(result, dataQualityVerifyDTO, dataQualityVerifyEnum);
//                    // 增量信息
//                    runnables.add(() -> startDataQualityError(buildLogId));
//                }
//            }
//        }
//        // 开启线程
//        runnables.forEach(executor::execute);
//        // 缓存进度
//        result.forEach(item -> {
//            dataQualityPlanCache(item.getLogId(), 10);
//        });
//        // 返回结果
//        return result;
//    }
//
//    *//**
//     * 先生成比对记录id
//     *
//     * @param dataQualityVerifyDTO  DataQualityVerifyDTO
//     * @param result                List<SsDataQualityLogVO>
//     * @param dataQualityVerifyEnum DataQualityVerifyEnum
//     * @return DataQualityVerifyDTO
//     *//*
//    private DataQualityVerifyDTO buildLogId(List<SsDataQualityLogVO> result, DataQualityVerifyDTO dataQualityVerify, DataQualityVerifyEnum dataQualityVerifyEnum) {
//        DataQualityVerifyDTO dataQualityVerifyDTO = new DataQualityVerifyDTO();
//        // 先生成对应的比对id信息
//        SsDataQualityLog ssDataQualityLog = new SsDataQualityLog();
//        ssDataQualityLog.setId(null);
//        ssDataQualityLog.setDataQualityConfigId(Long.valueOf(dataQualityVerify.getConfigId()));
//        ssDataQualityLog.setQualityType(dataQualityVerifyEnum.name());
//        ssDataQualityLog.setUpdateDate(DateUtil.now());
//        ssDataQualityLog.setUpdateUser(UserUtil.getUsername());
//        // 存储日志记录
//        this.dataQualityLogService.save(ssDataQualityLog);
//
//        SsDataQualityLogVO ssDataQualityLogVO = new SsDataQualityLogVO();
//        ssDataQualityLogVO.setLogId(StrUtil.toString(ssDataQualityLog.getId()));
//        ssDataQualityLogVO.setConfigId(dataQualityVerify.getConfigId());
//        ssDataQualityLogVO.setDataQualityVerifyEnum(dataQualityVerifyEnum);
//        result.add(ssDataQualityLogVO);
//        BeanUtil.copyProperties(dataQualityVerify, dataQualityVerifyDTO);
//        dataQualityVerifyDTO.setLogId(StrUtil.toString(ssDataQualityLog.getId()));
//        return dataQualityVerifyDTO;
//    }
//
//    *//**
//     * 比对进度缓存
//     *
//     * @param logId 记录唯一id
//     * @param plan  进度
//     *//*
//    private void dataQualityPlanCache(String logId, Object plan) {
//        redisCache.setCacheObject(StrUtil.format(MdmConstant.RedisConst.DATA_QUALITY_PLAN, logId), plan, 1, TimeUnit.DAYS);
//    }
//
//    @Override
//    public List<DataQualityTableVO> getDataQualityTable(DataQualityListDTO dataQualityListDTO) {
//        List<DataQualityTableVO> dataQualityTableVOS = this.baseMapper.selectDataQualityTable(dataQualityListDTO);
//        for (DataQualityTableVO dataQualityTableVO : dataQualityTableVOS) {
//            if (StrUtil.isNotBlank(dataQualityTableVO.getSourceTableCode())) {
//                dataQualityTableVO.setMapFlag(StatusWhetherEnum.STATUS_Y.getStatusCode());
//            } else {
//                dataQualityTableVO.setMapFlag(StatusWhetherEnum.STATUS_N.getStatusCode());
//            }
//            if (ObjectUtil.isNotEmpty(dataQualityTableVO.getDataQualityLog())) {
//                if (StrUtil.isNotBlank(dataQualityTableVO.getDataQualityLog().getMissingDataValue()) && StrUtil.isBlank(dataQualityTableVO.getDataQualityLog().getErrorDataValue())) {
//                    dataQualityTableVO.setVerifyFlag(dataQualityTableVO.getDataQualityLog().getMissingDataValue());
//                } else if (StrUtil.isBlank(dataQualityTableVO.getDataQualityLog().getMissingDataValue()) && StrUtil.isNotBlank(dataQualityTableVO.getDataQualityLog().getErrorDataValue())) {
//                    dataQualityTableVO.setVerifyFlag(dataQualityTableVO.getDataQualityLog().getErrorDataValue());
//                } else {
//                    dataQualityTableVO.setVerifyFlag(null);
//                }
//            }
//        }
//        return dataQualityTableVOS;
//    }
//
//    @Override
//    public void addDataQualityJob(SysJob job) {
//        job.setCreateBy("dataquality");
//        job.setInvokeTarget("dataQualityJob.execute('')");
//        job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
//        int rows = this.jobMapper.insertJob(job);
//        job.setInvokeTarget("dataQualityJob.execute('" + job.getJobId() + "')");
//        this.jobMapper.updateJob(job);
//        if (rows > 0) {
//            try {
//                ScheduleUtils.createScheduleJob(this.scheduler, job);
//            } catch (Exception e) {
//                throw new BizException("添加数据质量任务", e);
//            }
//        }
//    }
//
//    @Override
//    public void dataQualityBindJob(DataQualityJobDTO dataQualityJob) {
//        dataQualityJob.getConfigIds().forEach(item -> {
//            SsDataQualityConfig byId = this.getById(item);
//            if (ObjectUtil.isNotEmpty(dataQualityJob.getContentJobId())) {
//                byId.setContentComparisonCycle(Long.valueOf(dataQualityJob.getContentJobId()));
//            }
//            if (ObjectUtil.isNotEmpty(dataQualityJob.getNumberJobId())) {
//                byId.setNumberComparisonCycle(Long.valueOf(dataQualityJob.getNumberJobId()));
//            }
//            byId.setTaskDateRange(dataQualityJob.getTaskDateRange());
//            byId.setUpdateDate(DateUtil.now());
//            byId.setUpdateUser(UserUtil.getUsername());
//            this.updateById(byId);
//        });
//    }
//
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public void removeDataQualityConfig(List<String> configIds) {
//        configIds.forEach(id -> {
//            this.dataQualityConfigItemService.remove(Wrappers.lambdaUpdate(SsDataQualityConfigItem.class).eq(SsDataQualityConfigItem::getDataQualityConfigId, id));
//            this.dataQualityLogService.remove(Wrappers.lambdaUpdate(SsDataQualityLog.class).eq(SsDataQualityLog::getDataQualityConfigId, id));
//            this.removeById(id);
//        });
//    }*/
//}
